$(function () {
    mui.init();
    
    var stit = localStorage.getItem('cstit');
    var map = new BMap.Map("lift-map");

    mui.ready(function () {
        //加载框
        mui.showLoading("正在加载..", ".warn-list");
        var lag = localStorage.getItem('lng');
        var lat = localStorage.getItem('lat');
        liftMap(lag, lat, stit);
        //隐藏加载框
        mui.hideLoading(function () { //隐藏后的回调函数  
        });
    });
    /*百度地图*/
    function liftMap(lag, lat, tit) {

        var ggPoint = new BMap.Point(lag, lat);
        map.centerAndZoom(ggPoint, 14);
        map.addControl(new BMap.NavigationControl());
        translateCallback = function (data) {
            if (data.status === 0) {
                var marker = new BMap.Marker(data.points[0]);
                //默认动画
                map.addOverlay(marker); //将标注添加到地图中
                // 创建标注
                var label = new BMap.Label(tit, {
                    offset: new BMap.Size(-20, 30)
                });
                label.setStyle({
                    width: "auto",
                    color: '#fff',
                    background: 'rgba(0,0,0,0.5)',
                    border: 'none',
                    borderRadius: "5px",
                    textAlign: "center",
                    height: "24px",
                    lineHeight: "24px",
                    padding: '0 3px '
                });
                marker.setLabel(label);
                map.setCenter(data.points[0]);

            }
        };
        setTimeout(function () {
            var convertor = new BMap.Convertor();
            var pointArr = [];
            pointArr.push(ggPoint);
            convertor.translate(pointArr, 1, 5, translateCallback)
        }, 1000);
        //添加导航控件
        map.addControl(new BMap.NavigationControl());
        //添加缩放控件
        map.addControl(new BMap.ScaleControl());
        map.enableScrollWheelZoom(); //启用滚轮放大缩小，默认禁用

    }


})